<?php
$action = $_REQUEST['action'];
$cote = $_REQUEST['cote'];
$categorie = $_REQUEST['categorie'];
if (!$action || !$cote || !$categorie){
	echo 'Erreur de transfert';
}
else{
	include 'infobd.php';
	include 'accent.php';

    $categorie = str_replace($normalaccent, $codeaccent, $categorie);
 
	$con = mysql_connect($serv,$user,$passw);
	if (!$con)
  	{
  		die('Could not connect: ' . mysql_error());
  	}
 
	mysql_select_db($db, $con);
 
	$requete = "";
	if($action == "add"){
		$requete = sprintf("insert into categorie (cat) values('%s')",
			mysql_real_escape_string($categorie));
	}
	if($action == "del"){
		$requete = sprintf("delete from categorie where cote = '%s'",
			mysql_real_escape_string($cote));
	}
	if($action == "mod"){
		$requete = sprintf("update categorie set cat = '%s' where cote = '%s'",
			mysql_real_escape_string($categorie),
			mysql_real_escape_string($cote));
	}
 
	if ($requete != ""){
		if (!mysql_query($requete,$con))
		{
			die('Error: ' . mysql_error());
		}
	}
	mysql_close($con);
        include 'selectadmincat.php';
}
?>	